#!/usr/bin/env python
# -*- coding: utf-8 -*-
#

import unittest

from jute.db import Column

class   Column01TestCase(unittest.TestCase) :
    def setUp(self) :
        pass
        ## setUp()

    def tearDown(self) :
        pass
        ## tearDown()

    def testSetter(self) :
        c = Column('C','Hello,Column.',1234)

        self.assertEqual(c.name, 'C')
        self.assertEqual(c.value, 'Hello,Column.')
        self.assertEqual(c.timestamp, 1234)
        self.assertEqual(c.markedForDelete, False)
        self.assertRaises(RuntimeError, c.getMarkedForDeleteAt)
        ## testSetter()

    def testSerialize(self) :
        c = Column('C','Hello,Column.',1234)
        self.doTestSerialize(c)

        c = Column('C','Hello,Column!',4321, True)
        self.doTestSerialize(c)
        ## testSerialize()

    def doTestSerialize(self, c) :
        serialized = Column.Serializer.serialize(c)
        #print serialized
        d = Column.Serializer.deserialize(serialized)
        #print d

        self.assertTrue(isinstance(d, Column))
        self.assertEqual(c, d)
        self.assertEqual(c.name, d.name)
        self.assertEqual(c.value, d.value)
        self.assertEqual(c.timestamp, d.timestamp)
        self.assertEqual(c.markedForDelete, d.markedForDelete)
        ## doTestSerialize()

    ## class ColumnTestCase


if __name__ == '__main__' :
    unittest.main()

